package fafu.edu.wcy.springdemo.controller;

import fafu.edu.wcy.springdemo.dao.IArticlsDao;
import fafu.edu.wcy.springdemo.entity.Article;
import fafu.edu.wcy.springdemo.service.IArticleService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/article")
public class ArticleController {
    @Autowired
    IArticleService articleService;

    @RequestMapping ("add")
    Integer add( @RequestBody Article article) {
        Integer i = articleService.insertArticle(article);
        System.out.println("收到"+article);
        return i;
    }

    @RequestMapping("findArticle")
    List<Article> findArticle(@RequestBody Article article) {
        System.out.println(article);
        return articleService.findArticls(article);
    }

    //'findArticleIndex'
    @RequestMapping("findArticleIndex")
    List<Article> findArticleIndex(@RequestBody Article article) {
        System.out.println(article);
        return articleService.findArticlsAll();
    }
}
